package servlet;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import javax.security.auth.message.callback.PrivateKeyCallback.Request;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import entity.profit;
import service.profit_service;

public class profit_servlet extends HttpServlet
{

	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException
	{
		// TODO Auto-generated method stub
		doPost(req, resp);
	}

	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException
	{
		System.out.println("-----------doPost-------");
		
		// TODO Auto-generated method stub
		ArrayList<profit> list = null;
		profit_service service = new profit_service();
		list = service.getProfit();

		req.getSession().setAttribute("profit", list);
		
		System.out.println(req.getContextPath());
		
		resp.sendRedirect(req.getContextPath() + "/index.jsp");
	}

}
